﻿<phone:PhoneApplicationPage 
    x:Class="MobiSms.Wasun.Views.PreferenceView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:viewmodel="clr-namespace:MobiSms.ViewModel;assembly=MobiSms.ViewModel"
    xmlns:UX="clr-namespace:MobiSms.UX;assembly=MobiSms.UX"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False" Title="">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.DataContext>
            <viewmodel:PreferenceViewModel/>
        </Grid.DataContext>
        <Grid.Background>
            <ImageBrush ImageSource="{Binding GlobalSettings.BackgroundImage}" Stretch="{Binding GlobalSettings.BackgroundImageStretch}" />
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{StaticResource IDS_APP_NAME}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{StaticResource IDS_PREFERENCE_TITLE}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <ScrollViewer>
                <StackPanel>
                    <toolkit:ListPicker Header="{StaticResource IDS_PREFERENCE_DIAPLAYLANGUAGE}" 
                                        ItemsSource="{Binding Languages}" 
                                        SelectedItem="{Binding GlobalSettings.Language, Mode=TwoWay}">
                        <toolkit:ListPicker.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Converter={StaticResource CultureNameToNativeNameConverter}}"/>
                            </DataTemplate>
                        </toolkit:ListPicker.ItemTemplate>
                    </toolkit:ListPicker>

                    <UX:UXTextMenu Content="{StaticResource IDS_PREFERENCE_CHOOSEIMAGE}" 
                                   Uri="/Views/GalleryView.xaml"/>

                    <toolkit:ListPicker Header="{StaticResource IDS_PREFERENCE_STRETCH}" 
                                        ItemsSource="{Binding GlobalSettings.StretchCollection}" 
                                        SelectedItem="{Binding GlobalSettings.BackgroundImageStretch, Mode=TwoWay}">
                        <toolkit:ListPicker.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Converter={StaticResource EnumTranslateConverter}}"/>
                            </DataTemplate>
                        </toolkit:ListPicker.ItemTemplate>
                    </toolkit:ListPicker>

                    <toolkit:ToggleSwitch Header="{StaticResource IDS_PREFERENCE_NOTIFYBIRTHDAY}" 
                                          IsChecked="{Binding GlobalSettings.ShowRecentBirthday,Mode=TwoWay}" />
                    <StackPanel Visibility="{Binding GlobalSettings.ShowRecentBirthday, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" 
                                       Text="{StaticResource IDS_PREFERENCE_NOTIFICATIONDAYS}"/>
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" 
                                       Text="{Binding GlobalSettings.NotifyDays}" 
                                       Grid.Column="1"/>
                        </Grid>
                        <Slider Minimum="1" 
                                Maximum="31" 
                                Value="{Binding GlobalSettings.NotifyDays, Mode=TwoWay, StringFormat=\{0:F0\}}" />
                    </StackPanel>

                    <UX:UXTextMenu Content="{StaticResource IDS_HOME_MENU_LOG}" Uri="/Views/LogView.xaml"/>
                </StackPanel>
            </ScrollViewer>

            <UX:UXIconTextButton Path="{StaticResource PATH_ICON_CLEAN}"
                                 Grid.Row="1" Margin="0,12" 
                                 Command="{Binding CleanCommand}"
                                 Content="{StaticResource IDS_PREFERENCE_CLEAN_DATA}" 
                                 HorizontalAlignment="Left"/>
        </Grid>
    </Grid>
 
    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>
